<?php
/**
 * TomatoCMS
 *
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 *
 * @copyright    Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license        http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version     $Id: list.phtml 3032 2010-05-25 08:00:42Z huuphuoc $
 */
?>
<?php
$this->headTitle($this->translator('assignment_view_page_title'));

$this->headLink()
    ->appendStylesheet($this->APP_STATIC_SERVER.'/js/jquery.ui/themes/base/ui.core.css')
    ->appendStylesheet($this->APP_STATIC_SERVER.'/js/jquery.ui/themes/base/ui.resizable.css')
    ->appendStylesheet($this->APP_STATIC_SERVER.'/js/jquery.ui/themes/base/ui.dialog.css')
    ->appendStylesheet($this->APP_STATIC_SERVER.'/js/jquery.ui/themes/base/ui.theme.css');

$this->headScript()
    ->appendFile($this->APP_STATIC_SERVER.'/js/jquery.ui/ui.core.js')
    ->appendFile($this->APP_STATIC_SERVER.'/js/jquery.ui/ui.draggable.js')
    ->appendFile($this->APP_STATIC_SERVER.'/js/jquery.ui/ui.droppable.js')
    ->appendFile($this->APP_STATIC_SERVER.'/js/jquery.ui/ui.resizable.js')
    ->appendFile($this->APP_STATIC_SERVER.'/js/jquery.ui/ui.dialog.js');
?>
<style>
    .t_a_bottom span{
        height:26px;
        line-height:26px;
        text-align:right;
        width:140px;
    }
    .t_a_bottom label {
        display:block;
        float:left;
        height:26px;
        margin-right:0px;
        text-align:left;
        line-height:26px;
        width:100px;
    }
</style>

<div class="grid_12 t_a_ui_breadcrumb">
    <span><a href="<?php echo $this->url(array(), 'assignment_assignment_list');?>"><?php echo $this->translator('aissgnment_list_breadcump'); ?></a></span>
    <span><?php echo $this->translator('aissgnment_view_breadcump'); ?></span>
</div>
<?php

    /**
    * Assignment info
    **/
    $assignment = $this->assignment;

    /**
     * Producer info
    **/
    $producer = $this->producer;
    $pro_name = '-';
    if($producer){
        $pro_name = (trim($producer->full_name))?$producer->full_name:$producer->user_name ;
    }

    /**
     * Assigner info
    **/
    $assigner = $this->assigner;
    $as_name = '-';
    if($assigner){
        $as_name = (trim($assigner->full_name))?$assigner->full_name:$assigner->user_name ;
    }

    /**
     * Current user
     **/
    $user = $this->user;

    /**
     * Customer
    **/
    $customer = $this->customer;
?>
<?php if(!$this->isAllowed):?>
<div class="grid_12"><?php echo $this->translator('assignment_permission_guide');?></div>
<?php else:?>

<div class="grid_12 t_a_bottom">
    <!--Assignment info-->
    <div class="grid_6 alpha">
        <div class="t_a_ui_helper_line grid_5">
            <h3><?php echo $this->translator('assignment_view_guide');?></h3>
        </div>
        <div class="clearfix t_a_bottom">
            <div class="grid_3 alpha">
                <label><?php echo $this->translator('assignment_id'); ?>:</label>
                <span><?php echo isset($assignment->assignment_id)?$assignment->assignment_id:null;?></span>
            </div>
            <div class="grid_3 omega">
                <label style="font-size:10pt; font-weight:bold; color:#F2F2F2; width:100%;"><?php echo $this->translator('assignment_status_'.$this->status);?></label>
            </div>
        </div>

        <div class="clearfix t_a_bottom">
            <div class="grid_3 alpha">
                <label><?php echo $this->translator('assignment_assigner'); ?>:</label>
                <span><?php echo $as_name; ?></span>
            </div>
            <div class="grid_3 omega">
                <label><?php echo $this->translator('assignment_producer'); ?>:</label>
                <span><?php echo $pro_name; ?></span>
            </div>
        </div>

        <div class="clearfix t_a_bottom">
            <div class="grid_3 alpha">
                <label><?php echo $this->translator('assignment_create_date'); ?>:</label>
                <span><?php echo isset($assignment->assignment_create_date)?date('d-m-Y',strtotime($assignment->assignment_create_date)):'-';?></span>
            </div>
            <div class="grid_3 omega">
                <label><?php echo $this->translator('assignment_due_date'); ?>:</label>
                <span><?php echo isset($assignment->assignment_due_date)?date('d-m-Y',strtotime($assignment->assignment_due_date)):'-';?></span>
            </div>
        </div>

        <div class="clearfix t_a_bottom">
            <div class="grid_3 alpha">
                <label><?php echo $this->translator('assignment_finish_date'); ?>:</label>
                <span><?php echo isset($assignment->assignment_finish_date)?date('d-m-Y',strtotime($assignment->assignment_finish_date)):'-';?></span>
            </div>
        </div>
    </div>
    <!--Form action-->
    <form action="" method="POST" id="frmSaveStatus">
    <div class="grid_6 omega">
        <div class="clearfix t_a_bottom">
            <div class="t_a_ui_helper_line grid_5">
                <h3><?php echo $this->translator('assignment_action');?></h3>
            </div>
            <div class="grid_6 alpha">
                <?php echo $this->flashMessenger(); ?>
            </div>
        </div>
        <div class="clearfix t_a_bottom">
            <div class="grid_6 alpha">
                <?php if(count($this->arrSteps) > 0):?>
                <label><?php echo $this->translator('assignment_follow_steps'); ?>:</label>
                <span>
                    <?php $flag = false; foreach($this->arrSteps as $key=>$step):?>
                    <?php if(strstr($step->performer_role_id_chain,','.$user->role_id.',')):?>
                    <input type="radio" name="process_id" value="<?php echo ($this->arrProcess)?$this->arrProcess[$key]:null;?>"> <?php echo $this->translator('assignment_step_'.$step->code);?>&nbsp;&nbsp;
                    <input type="hidden" value="<?php echo $step->code;?>" name="step_code_<?php echo $this->arrProcess[$key];?>" >
                    <?php $flag = true; endif;?>
                    <?php endforeach;?>
                    <?php if($this->arrProducer):?>
                        <select name="producer_account_id">
                        <?php foreach($this->arrProducer as $producer):?>
                            <option <?php if($assignment->producer_account_id == $producer->user_id):?>selected<?php endif;?> value="<?php echo $producer->user_id;?>">
                                <?php echo trim($producer->full_name)?$producer->full_name:$producer->user_name;?>
                            </option>
                        <?php endforeach;?>
                        </select>
                    <?php endif;?>
                </span>
                <?php endif;?>
            </div>
            <div class="grid_6 alpha">
                <?php if(count($this->arrSteps) > 0 && $flag):?>
                <div class="grid_3 alpha"">
                    <div style="font-size:9px;"><?php echo $this->translator('assignment_note');?> (<?php echo date('d-m-Y');?>, <?php echo trim($user->full_name)?$user->full_name:$user->user_name;?>):</div>
                    <textarea style="width:200px; height:80px; font-size:9.5px;" name="assignment_notes"></textarea>
                    <button type="submit" style="margin-left: 125px;"><span style="width:25px; height:28px; line-height:28px;"><?php echo $this->translator('assignment_btn_save')?></span></button>
                </div>
                <?php endif;?>
                <div class="grid_3 omega">
                    <div style="height:100px; overflow:auto; text-align:justify; padding:3px;">
                    <?php echo $assignment->assignment_notes;?>
                    </div>
                    <?php if(trim($assignment->assignment_notes)):?>
                    <div style="text-align:right;">
                        <a href="javascript:void(0)" id="btnNotes"><?php echo $this->translator('assignment_notes_details');?></a>
                    </div>
                    <div id="dialogNotes"><?php echo $assignment->assignment_notes;?></div>
                    <?php endif;?>
                </div>
            </div>
        </div>
    </div>
    </form>
    <!--end form-->
 </div>

<!--Order detail info-->
<div class="grid_12">
    <div class="t_a_ui_helper_line">
        <h3><?php echo $this->translator('assignment_view_orderdetail_guide');?></h3>
    </div>
</div>
<div class="grid_12 t_a_ui_data_list_header">
    <div class="grid_5 alpha"><?php echo $this->translator('assignment_product_name'); ?></div>
    <div class="grid_7 omega"><?php echo $this->translator('assignment_product_attribute'); ?></div>
</div>
<div class="grid_12 t_a_bottom" id="articles">
    <div class="clearfix t_a_ui_data_list_content">
        <div class="grid_5 alpha"><?php echo $this->product->product_admin_name;?></div>
        <div class="grid_7 omega">
            <?php foreach($this->arrAtVal as $row):?>
                <div class="grid_3"><b><?php echo $row[0]?>:</b> <?php echo $row[1]?></div>
            <?php endforeach;?>
        </div>
    </div>
</div>

<!--Customer info-->
<div class="grid_12">
    <div class="t_a_ui_helper_line">
        <h3><?php echo $this->translator('assignment_view_customer_guide');?></h3>
    </div>
</div>
<?php echo $this->widget('customer','customerinfo',array('user_id'=>$this->customer_id)); ?>
<!--End customer info-->

<!--Customer notice-->
<?php if(trim($this->customer_notice)):?>
<div class="grid_12 t_a_bottom">
    <div class="t_a_ui_helper_line">
        <h3><?php echo $this->translator('assignment_view_customer_notice_guide');?></h3>
    </div>
</div>
<div class="grid_12 t_a_bottom">
    <div class="prefix_1 suffix_1">
        <div class="clearfix t_a_bottom" style="text-align:justify;">
            <?php echo $this->customer_notice;?>
        </div>
    </div>
</div>
<?php endif;?>

<?php endif;?>

<div id="messageDialog"></div>
<div id="confirmDialog"></div>

<script type="text/javascript">
$(document).ready(function() {

    $('#btnNotes').click(function() {
        $("#dialogNotes").dialog('open');
    });
    var dialogOpts = {
        title: "<?php echo $this->translator('assignment_notes_details')?>",
        modal: true,
        autoOpen: false,
        height: 500,
        width: 500,
        open: function() {
        }
    };
    $('#dialogNotes').dialog(dialogOpts);

});
</script>